home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0074_More RIP Bezier Curves.pas < prev    next >
Pascal/Delphi Source File  |  1994-02-03  |  1KB  |  49 lines

  1. {
  2. From: SCOTT BRADSHAW
  3. Subj: RIP BEZIER CURVES
  4. ---------------------------------------------------------------------------
  5. Well, I had a whole RIP unit I made for Turbo Pascal over the modem,
  6. but it got lost in a HD crash. I am really not that interested in
  7. RIP anymore, but I will give you mu source to the Bezier Curve. It
  8. should be pretty close to what your looking for...
  9. }
  10. program bezier;
  11. uses graph,crt;
  12.  
  13. procedure Bezier_2D_Curve( x, y, cx,cy,a,b,ca,cb:integer;incr:real);
  14. var
  15.    qx, qy :real;
  16.    q1, q2, q3, q4:real;
  17.    plotx, ploty:integer;
  18.    t:real;
  19.  
  20.     begin
  21.       t := 0;
  22.     while (t <= 1) do begin
  23.       q1 := t*t*t*-1 + t*t*3 + t*-3 + 1;
  24.       q2 := t*t*t*3 + t*t*-6 + t*3;
  25.       q3 := t*t*t*-3 + t*t*3;
  26.       q4 := t*t*t;
  27.       qx := q1*x + q2*cx + q3*a + q4*ca;
  28.       qy := q1*y + q2*cy + q3*b + q4*cb;
  29.       plotx := round(qx);
  30.       ploty := round(qy);
  31.       putpixel( plotx, ploty, 15);
  32.       t := t + incr;
  33.    end;
  34. end;
  35.  
  36. var gd,gm:integer;
  37.     c:char;
  38. begin
  39.    gd := VGA;
  40.    gm := VGAHI;
  41.    initgraph(gd,gm,'\turbo\tp');
  42.    setcolor( BLUE );
  43.    Bezier_2D_Curve( 100, 400, 25, 450, 120, 275, 300, 455,0.003 );
  44.    c:=readkey;
  45.    Bezier_2D_Curve( 310, 200, 360, 150, 510, 200, 460, 250,0.003 );
  46.    c:=readkey;
  47. end.
  48.  
  49.